//
// Created by 11510 on 2024/7/16.
//

#ifndef INC_03_SIGNAL_SLOT_C_H
#define INC_03_SIGNAL_SLOT_C_H

#include <QObject>
#include <QDebug>

class C : public QObject {
Q_OBJECT
public:
    explicit C(QObject *parent = nullptr) :
            QObject(parent) {
        /**
         * 多次关联会调用多次
         */
        QObject::connect(this, QOverload<int>::of(&C::mySignal),
                         this, QOverload<int>::of(&C::mySlot));
        QObject::connect(this, QOverload<int>::of(&C::mySignal),
                         this, QOverload<int>::of(&C::mySlot));
        QObject::connect(this, QOverload<int, int>::of(&C::mySignal),
                         this, QOverload<int, int>::of(&C::mySlot));
    }

signals:

    void mySignal();

    void mySignal(int);

    void mySignal(int, int);

private slots:

    void mySlot() {
        qDebug() << "slot 0";
    }

    void mySlot(int value) {
        qDebug() << "value = " << value;
    }

    void mySlot(int value1, int value2) {
        qDebug() << "value1 = " << value1
                 << "value1 = " << value2;
    }
};


#endif //INC_03_SIGNAL_SLOT_C_H
